package com.mall.controller.goods;

import com.mall.entity.PageResult;
import com.mall.service.goods.BrandService;
import com.mall.pojo.goods.Brand;
import org.apache.dubbo.config.annotation.DubboReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/brand")
public class BrandController {

    private static Logger log = LoggerFactory.getLogger(BrandController.class);

    @DubboReference
    private BrandService brandService;


    @GetMapping("/findAll")
    public List<Brand> findAll(){
        return brandService.findAll();
    }

    @GetMapping("/findPage")
    public PageResult<Brand> findPage(int page, int size){
        log.info("brandfindpage");
        return brandService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<Brand> findList(@RequestBody Map<String,Object> searchMap){
        return brandService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<Brand> findPage(@RequestBody Map<String,Object> searchMap,int page, int size){
        return  brandService.findPage(searchMap,page,size);
    }

    @GetMapping("/findByCategoryId")
    public List<Brand> findByCategoryId(Integer categoryId){
        return brandService.findByCategoryId(categoryId);
    }


    @GetMapping("/findById")
    public Brand findById(Integer id){
        return brandService.findById(id);
    }


}